<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<title>用户登录 -- {$tpshop_config['shop_info_store_title']}</title>
<meta name="keywords" content="{$tpshop_config['shop_info_store_keyword']}" />
<meta name="description" content="{$tpshop_config['shop_info_store_desc']}" />
<link rel="stylesheet" href="__STATIC__/css/user.css" type="text/css">
</head>
<body>
<include file="Public/header" />
<include file="Public/topnav" />

<div class="page_pad">
  <div class="page_margin">
    <div class="page_radius page_hidden">
      <div class="login_left"><img src="__STATIC__/images/login_left.jpg" /></div>
      <div class="login_right">
        <div class="login_pad">
          <form action="{:U('Home/User/do_login')}" method="post">
            <div class="login_tit">用户登录</div>
            <input type="hidden" name="referurl" id="referurl" value="{$referurl}">
            <div class="ginput_div ginput_div_icon"><i class="icon-yonghu"></i><input class="ginput" type="text" id="username" name="username"  onkeydown="if(event.keyCode==13){checkSubmit();}" placeholder="手机号/邮箱" /></div>
            <div class="ginput_div ginput_div_icon"><i class="icon-mima"></i><input class="ginput" name="password" id="password" type="password" onKeyDown="if(event.keyCode==13){checkSubmit();}" placeholder="请输入密码" /></div>
            <div class="ginput_div ginput_div_icon"><i class="icon-yanzhengma2"></i><input class="ginput" onKeyDown="if(event.keyCode==13){checkSubmit();}" type="text" name="verify_code" id="verify_code" placeholder="请输入验证码" maxlength="4" /><span class="code"><img id="verify_code_img" src="{:U('Home/User/verify')}" onclick="verify(this)" /></span></div>
            <div class="login_forgot">
              <div class="fl">
                <p>
                    <a href="{:U('User/forget_pwd')}">忘记密码?</a> &nbsp;&nbsp;
                    <a href="{:U('Home/User/reg')}">注册账号</a> &nbsp;&nbsp;
                   <a href="{:U('LoginApi/wx_login',array('oauth'=>'weixin'))}"><span class="lo_wechat"><i class="icon-weixin"></i></span>微信登录</a>
                   <!--<a href="{:U('LoginApi/wx_login',array('oauth'=>'weixin'))}">.</a>-->
                </p>
              </div>
              <div class="fr"><button type="button" class="login_sub" onClick="checkSubmit()">{$Think.lang.loginsubmit}</button></div>
              <div class="clear"></div>
            </div>
          </form>
        </div><!--login_pad-->
      </div><!--login_right-->
      <div class="clear"></div>
    </div><!--page_radius-->
  </div><!--page_margin-->
</div><!--page_pad-->


<include file="Public/footer" />

<script>
    function verify(){
       $('#verify_code_img').attr('src','/index.php?m=Home&c=User&a=verify&r='+Math.random());
    }

	function checkSubmit()
	{
		var username = $.trim($('#username').val());
		var password = $.trim($('#password').val());
		var referurl = $('#referurl').val();
		var verify_code = $.trim($('#verify_code').val());
		if(username == ''){
			$.artTip('用户名不匹配.', 800);
			return false;
		}

		if(password == ''){
			$.artTip('密码不能为空', 800);
			return false;
		}
		/*if(verify_code == ''){
			$.artTip('驗證碼不能為空', 800);
			return false;
		}*/

		$.ajax({
			type : 'post',
			//url : '/index.php?m=Home&c=User&a=do_login&t='+Math.random(),
			url : "{:U('Home/User/do_login')}?t="+Math.random(),
			//   /index.php?m=Home&c=User&a=do_login&t='+Math.random(),
			data : {username:username,password:password,referurl:referurl,verify_code:verify_code},
			dataType : 'json',
			success : function(res){
				if(res.status == 1){
					window.location.href = res.url;
				}else{
					$.artTip(res.msg, 800);
					verify();
				}
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				//showErrorMsg('網絡失敗，請刷新頁面後重試');
				$.artTip('網絡失敗，請刷新頁面後重試', 800);
			}
		})

	}

    function checkMobile(tel) {
        var reg = /(^1[3|4|5|7|8][0-9]{9}$)/;
        if (reg.test(tel)) {
            return true;
        }else{
            return false;
        };
    }

    function checkEmail(str){
        var reg = /^[a-z0-9]([a-z0-9\\.]*[-_]{0,4}?[a-z0-9-_\\.]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+([\.][\w_-]+){1,5}$/i;
        if(reg.test(str)){
            return true;
        }else{
            return false;
        }
    }

    function showErrorMsg(msg){
    	alert(msg);
    }
</script>

</body>
</html>